#! /bin/bash

if [[ $# != 2 ]];then
  echo -e "\e[31m -usage:\e[39m   ${0} SECRET_NAME NAMESPACE"
  echo " -example: ${0} web-ssl demo"
  echo " "
  exit 1
fi
secret_name=$1
namespace=$2

set -euo pipefail

root_directory="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/../.."

generate_secret_manifest="${root_directory}/deploy/kubernetes/templates/generate_secret_manifest"
${generate_secret_manifest} ${secret_name} ${namespace}

kubectl="${root_directory}/deploy/clis/kubectl"
manifest_directory_in_container="deploy/kubernetes/manifests"
${kubectl} delete -f ${manifest_directory_in_container}/${secret_name}.yml || true
${kubectl} create -f ${manifest_directory_in_container}/${secret_name}.yml
